package api.app;

import java.io.IOException;

import org.json.JSONException;
import org.json.JSONObject;

import common.Host;
import common.Request;

/**
 * 实现帮忙医APP创建图文咨询会话StartChat接口调用
 * @author maojj
 *
 */
public class StartChat
{
	/**
	 * 实现帮忙医APP创建图文咨询会话StartChat接口调用（有瑞慈体检报告）
	 * @param userID - 用户名ID
	 * @param userName - 用户名
	 * @param userSex - 用户性别：男Man；女Woman
	 * @param age - 用户年龄
	 * @param studyID - 体检报告ID
	 * @param token - 用户token
	 * @return 接口返回数据
	 * @throws JSONException
	 * @throws IOException
	 */
	public static String post(
			int userID,
			String userName,
			String userSex,
			int age,
			String studyID,
			String token) throws JSONException, IOException
	{
		//拼接接口地址
		String url = Host.getAddress() + "/api/AppClient/StartChat";
				
		//给接口参数赋值
		JSONObject parms = new JSONObject();
		parms.put("SubjectType", 1);
		parms.put("UserID", userID);
		parms.put("UserName", userName);
		parms.put("UserSex", userSex);
		parms.put("Age", age);
		parms.put("StudyID", studyID);
	
		//调用接口并返回接口结果
		String result = Request.post(url, parms, token);
		return result;
	}
	
	/**
	 * 实现帮忙医APP创建图文咨询会话StartChat接口调用（无瑞慈体检报告）
	 * @param userID - 用户名ID
	 * @param userName - 用户名
	 * @param userSex - 用户性别：男Man；女Woman
	 * @param age - 用户年龄
	 * @param headPicture - 用户头像
	 * @param relationShip - 体检人与咨询人关系
	 * @param studyID - 体检报告ID
	 * @param attachPics - 数组，元素为咨询图片URL
	 * @param bodyContent - 咨询内容
	 * @param token - 用户token
	 * @return 接口返回数据
	 * @throws JSONException 
	 * @throws IOException 
	 */
	public static String post(
			int userID,
			String userName,
			String userSex,
			int age,
			String headPicture,
			String relationShip,
			String studyID,
			String[] attachPics,
			String bodyContent,
			String token) throws JSONException, IOException
	{
		//拼接接口地址
		String url = Host.getAddress() + "/api/AppClient/StartChat";
				
		//给接口参数赋值
		JSONObject parms = new JSONObject();
		parms.put("SubjectType", 3);
		parms.put("UserID", userID);
		parms.put("UserName", userName);
		parms.put("UserSex", userSex);
		parms.put("Age", age);
		parms.put("HeadPicture", headPicture);
		parms.put("RelationShip", relationShip);
		parms.put("StudyID", studyID);
		parms.put("AttachPics", attachPics);
		parms.put("BodyContent", bodyContent);
	
		//调用接口并返回接口结果
		String result = Request.post(url, parms, token);
		return result;
	}
}
